/**
 * Jan 5, 2012 7:43:58 AM
 * com.kratonsolution.cbs.security.dm
 * GrantedAccess.java
 */
package com.kratonsolution.belian.security.api.dm;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Type;

import com.kratonsolution.belian.kernel.dm.Model;


/**
 * @author Agung Dodi Perdana
 * @email agung.dodi.perdana@gmail.com
 * @Version Sinch 0.0.1
 */
@Entity
@Table(name="cbs_security_granted_access")
@Cacheable
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
public class Access extends Model
{
    private static final long serialVersionUID = -5742205397235327791L;
    
    @Column(name="can_read")
    @Type(type="yes_no")
    private boolean read;
    
    @Column(name="can_add")
    @Type(type="yes_no")
    private boolean add;

    @Column(name="can_update")
    @Type(type="yes_no")
    private boolean update;
    
    @Column(name="can_delete")
    @Type(type="yes_no")
    private boolean delete;
    
    @Column(name="can_print")
    @Type(type="yes_no")
    private boolean print;
    
    @Column(name="module_id")
    private String moduleId;

    @Column(name="module_code")
    private String moduleCode;
    
    @Column(name="module_name")
    private String moduleName;

    @Column(name="role_id")
    private String roleId;
    
    @Column(name="role_name")
    private String roleName;
    
    public Access(){}

    public boolean isAdd()
    {
        return add;
    }

    public void setAdd(boolean add)
    {
        this.add = add;
    }

    public boolean isRead()
    {
        return read;
    }

    public void setRead(boolean read)
    {
        this.read = read;
    }

    public boolean isUpdate()
    {
        return update;
    }

    public void setUpdate(boolean update)
    {
        this.update = update;
    }

    public boolean isDelete()
    {
        return delete;
    }

    public void setDelete(boolean delete)
    {
        this.delete = delete;
    }

    public boolean isPrint()
    {
        return print;
    }

    public void setPrint(boolean print)
    {
        this.print = print;
    }

    public String getModuleId()
    {
        return moduleId;
    }

    public void setModuleId(String moduleId)
    {
        this.moduleId = moduleId;
    }

    public String getModuleCode()
    {
        return moduleCode;
    }

    public void setModuleCode(String moduleCode)
    {
        this.moduleCode = moduleCode;
    }

    public String getModuleName()
    {
        return moduleName;
    }

    public void setModuleName(String moduleName)
    {
        this.moduleName = moduleName;
    }

    public String getRoleId()
    {
        return roleId;
    }

    public void setRoleId(String roleId)
    {
        this.roleId = roleId;
    }

    public String getRoleName()
    {
        return roleName;
    }

    public void setRoleName(String roleName)
    {
        this.roleName = roleName;
    }
    
    public static final Access withAllSelected()
    {
        Access access = new Access();
        access.setAdd(true);
        access.setDelete(true);
        access.setPrint(true);
        access.setRead(true);
        access.setUpdate(true);
        
        return access;
    }
    
    public static final Access withAllUnselected()
    {
        Access access = new Access();
        access.setAdd(false);
        access.setDelete(false);
        access.setPrint(false);
        access.setRead(false);
        access.setUpdate(false);
        
        return access;
    }
}